VScode找不到C++万能头文件<bits/stdc++.h>解决办法

您所在的位置:网站首页 为什么vs code下载不了 VScode找不到C++万能头文件<bits/stdc++.h>解决办法

VScode找不到C++万能头文件<bits/stdc++.h>解决办法

2024-07-17 14:40| 来源: 网络整理| 查看: 265

VScode找不到C++万能头文件解决办法 一、万能头文件介绍

万能头文件 中包含了 C++中大部分头文件,在大部分做题平台、比赛当中都支持万能头文件的包含,这样以来可以减少编写头文件的工作量,节约做题时间,让选手更加专注于算法本身。但是在程序编写时不推荐使用,万能头文件不是C++标准的一部分,减少了代码的可移植性。

二、出现问题 在使用VScode时发现万能头文件的包含语句下出现红色波浪线。 在这里插入图片描述 三、解决思路 出现问题的原因: VScode不能在头文件的搜素路径中找到头文件。解决方案 由于头文件中的语句只是一些文件包含语句,因此可以创建一个头文件,将其移动到系统的搜素路径下。 四、操作步骤

首先输入能搜素到的头文件 < iostream >

#include

在这里插入图片描述

通过此头文件找到头文件目录

选中 iostream ,右键转到定义 在这里插入图片描述

在 左侧右键点击 iostream 文件,在文件夹中显示 在这里插入图片描述 在这里插入图片描述

创建一个名为 stdc++.h 的文件,将以下代码复制到文件中保存

// C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2014 Free Software Foundation, Inc. This file is part of the GNU ISO C++ Library. This library is free// software; you can redistribute it and/or modify it under the// terms of the GNU General Public License as published by the// Free Software Foundation; either version 3, or (at your option)// any later version. // This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional// permissions described in the GCC Runtime Library Exception, version// 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and// a copy of the GCC Runtime Library Exception along with this program;// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see// . /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C #ifndef _GLIBCXX_NO_ASSERT #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #endif // C++ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif

在这里插入图片描述

将保存好的头文件放入之前打开的include目录下(需要管理员权限) 在这里插入图片描述

这时候返回vscode,发现红色下划线消失了 在这里插入图片描述

四、结果检测

用Hello word测试以下

#include using namespace std; int main() { cout


【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3